//package com.hanliukui.ai.langchain4j.assistant;
//
//import com.hanliukui.ai.langchain4j.assistant.domain.document.ChatMessageDoc;
//import com.hanliukui.ai.langchain4j.assistant.domain.repository.ChatMessagesDocRepository;
//import dev.langchain4j.data.message.ChatMessage;
//import dev.langchain4j.data.message.ChatMessageDeserializer;
//import dev.langchain4j.data.message.ChatMessageSerializer;
//import dev.langchain4j.store.memory.chat.ChatMemoryStore;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class MongoChatMemoryStore implements ChatMemoryStore {
//
//    private final ChatMessagesDocRepository repository;
//
//    public MongoChatMemoryStore(ChatMessagesDocRepository repository) {
//        this.repository = repository;
//    }
//
//    @Override
//    public List<ChatMessage> getMessages(Object memoryId) {
//        System.out.println(memoryId);
//        ChatMessageDoc chatMessageDoc = repository.findByMemoryId((String) memoryId);
//        if (chatMessageDoc == null) {
//            return new ArrayList<>();
//        }
//        return ChatMessageDeserializer.messagesFromJson(chatMessageDoc.getContent());
//    }
//
//    @Override
//    public void updateMessages(Object memoryId, List<ChatMessage> list) {
//        System.out.println(memoryId);
//        ChatMessageDoc document = repository.findByMemoryId((String) memoryId);
//        if (document == null) {
//            document = new ChatMessageDoc();
//            document.setMemoryId((String) memoryId);
//        }
//        document.setContent(ChatMessageSerializer.messagesToJson(list));
//        repository.save(document);
//    }
//
//    @Override
//    public void deleteMessages(Object memoryId) {
//        System.out.println(memoryId);
//        repository.deleteByMemoryId((String) memoryId);
//    }
//}
